<?php
namespace adapter;

class DbAdapter implements DatabaseInterface
{
    private $_adapter;

    public function __construct($adapterType)
    {
        switch($adapterType) {
            case 'mysqli':
                $this->_adapter = new MySQLi();
                break;
            case 'pdo':
                $this->_adapter = new PDO();
                break;
            default:
                throw new \Exception("没有适配到任何类，请检查~\n");
        }
    }
    public function connect($host, $port, $dbName, $user, $pwd)
    {
        return $this->_adapter->connect($host, $port, $dbName, $user, $pwd);
    }

    public function query($sql)
    {
        return $this->_adapter->query($sql);
    }

    public function close()
    {
        return $this->_adapter->close();
    }

}